<template>
  <div>
    <div class="tabs">
      <span v-bind:class="isAct?'active':''" v-on:click="handleEatSleep(true)">吃饭</span>
      <span v-bind:class="!isAct?'active':''" v-on:click="handleEatSleep(false)">睡觉</span>
    </div>
    <div class="cont" v-if="isAct">吃多少？</div>
    <div class="cont" v-if="!isAct">睡多久？</div>
  </div>
</template>

<script>
  export default {
    data(){
      return{
        isAct:true  //1.定数据
      }
    },
    methods: {
      // 3. 改数据
      handleEatSleep(bool){
        this.isAct = bool
      }
    },
  }
</script>

<style lang="scss" scoped>
.tabs {
  margin-bottom: 20px;
}
.tabs span{
  padding: 10px 20px;
  background-color: #d8d8d8;
}
.tabs span.active{
  background-color: orange;
  color: #fff;
}
.cont{
  width: 300px;
  height: 300px;
  border: 2px solid #333;
}
</style>